<?php

class Application_Form_GroupCreate extends Zend_Form {

    public function init() {
        $this->setMethod('post');
        $this->setAttrib("enctype", "multipart/form-data");

        $this->addElement('text', 'name', array(
            'label' => 'Name',
            'required' => true,
            'filters' => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 256)))));

        $this->addElement('textarea', 'description', array(
            'label' => 'Description',
            'required' => true,
            'cols' => 40,
            'rows' => 5,
            'filters' => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(0, 8192)))));

        $this->addElement('radio', 'imageType',
                array('label' => 'Image', 'required' => true));
        $this->imageType->addMultiOption("none", "None");
        $this->imageType->addMultiOption("upload", "By upload");
        $this->imageType->addMultiOption("url", "By URL");

        $this->addElement('file', 'imageUpload', array(
            'label'         => 'Upload image',
            'id'        => 'imageUpload',
            'required'      => false));

        $this->imageUpload->addValidator('Count', false, 1);
        $this->imageUpload->addValidator('Size', false, 256 * 1024);
        $this->imageUpload->addValidator('Extension', false, 'jpeg,jpg,png,gif');

        $this->addElement('text', 'imageUrl', array(
            'label' => 'Image URL',
            'required' => false,
            'id'        => 'imageUrl',
            'filters' => array('StringTrim')));


        $this->addElement('submit', 'submit', array(
            'label' => 'Create a group',
            'required' => false,
            'ignore' => true
        ));
    }

}
